export const namespace = "courseInfo";
export const id = "id";
import { Image } from "antd";
export const calcColumns = (params?) => {
  const columns = [
    {
      title: "课程主图",
      dataIndex: "courseCoverUrl",
      hideInSearch: true,
      valueType: "image",
      render: (_, record) => {
        return record.courseType != 3 ? (
          <Image
            width={80}
            height={45}
            src={record.courseCoverUrl && record.courseCoverUrl.split(",")[0]}
            fallback=""
          />
        ) : (
          "-"
        );
      },
    },
    {
      title: "课程名称",
      dataIndex: "courseName",
      width: 250,
      copyable: true,
      ellipsis: true,
    },
    // {
    //   title: "所属场馆",
    //   dataIndex: "venueId",
    //   valueEnum: params.venueList,
    //   ellipsis: true,
    //   render: (text, record) => {
    //     return record.venueName;
    //   },
    // },
    {
      title: "课程教练",
      dataIndex: "courseCoachId",
      valueEnum: params.courseCoachList,
      render: (text, record) => {
        return record.courseCoachName;
      },
    },
    {
      title: "可约人数",
      dataIndex: "peopleNumMax",
      hideInSearch: true,
      hidden: params.courseType === "1",
      render: (text, record) => {
        return record.peopleNumMax ? record.peopleNumMax + "人" : "-";
      },
    },
    {
      title: "课程时长",
      dataIndex: "courseDuration",
      hideInSearch: true,
      render: (text, record) => {
        return record.courseDuration ? record.courseDuration + "分钟" : "-";
      },
    },
    {
      title: "课程分类",
      dataIndex: "courseCategoryNameStrList",
      hideInSearch: true,
      render: (_, record) => {
        return <span>{record.courseCategoryNameStrList.toString()}</span>;
      },
    },
    {
      title: "状态",
      dataIndex: "courseStatus",
      valueEnum: {
        0: { text: "已上架", status: "Success" },
        1: { text: "已下架", status: "Error" },
        2: { text: "草稿", status: "default" },
      },
    },
    {
      title: "创建时间",
      dataIndex: "createTime",
      valueType: "dateRange",
      search: {
        transform: (value: any[]) => {
          return { startTime: value[0], endTime: value[1] };
        },
      },
      width: 180,
      render: (_: any, record: { createTime: any }) =>
        record.createTime ? record.createTime : "",
    },
  ];
  if (params?.operate) {
    const { operate } = params;
    if (operate?.length) {
      columns.push(...operate);
    }
    return columns;
  } else {
    return columns;
  }
};
